/**
 * 
 */
package com.ultimatetech.cim.graphical;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseMotionListener;
import org.eclipse.swt.widgets.Control;

public class PersistentToolTipListener 
implements MouseMotionListener {
	PersistentToolTip toolTipHelper = null;
	String toolTip = null;
	Figure figure = null;
	Control control = null;
	public PersistentToolTipListener(Figure f, String tooltip, Control c){
		 toolTip = tooltip;
		 figure = f;
		 control = c;
	  }
	public void mouseDragged(MouseEvent me) {
		// TODO Auto-generated method stub
		
	}

	public void mouseEntered(MouseEvent me) {
		if(toolTipHelper == null){			
			toolTipHelper = new PersistentToolTip(control);
		}
		//IFigure hoverSource = (IFigure)me.getSource();
		//IFigure tip = ((IFigure)control).getToolTip();
		//Control cntrl = (Control)me.getSource();
		org.eclipse.swt.graphics.Point absolute;
		absolute = control.toDisplay(new org.eclipse.swt.graphics.Point(me.x, me.y));
		toolTipHelper.displayToolTipNear(figure, new Label(toolTip), absolute.x, absolute.y);
		
	}

	public void mouseExited(MouseEvent me) {
		if(toolTipHelper != null){
			if (toolTipHelper.isShowing()) {
				toolTipHelper.hideToolTip();
			}
		}
		
	}

	public void mouseHover(MouseEvent me) {		
		
	}

	public void mouseMoved(MouseEvent me) {
		// TODO Auto-generated method stub
		
	}
	  
  }